const fs = require("fs");
const http = require("http");
const path = require("path");

http.createServer((req, res) => {
    console.log(req.url);
    if(req.url.indexOf("/data") >= 0) {
        let filePath = path.join(__dirname , "films.html");
        let fileContent = fs.readFileSync(filePath);
        res.end(fileContent);
    } else if(req.url === '/') {
        let fileContent = fs.readFileSync(path.join(__dirname , "index.html"));
        res.end(fileContent);
    } else if(req.url.indexOf("/show") >= 0) {
        let data = fs.readFileSync(path.join(__dirname , "data.json"));
        res.end(data);
    }
}).listen(3000)
